/**
 * Return an array of arrays of size *returnSize.
 * The sizes of the arrays are returned as *returnColumnSizes array.
 * Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().
 */
int** generate(int numRows, int* returnSize, int** returnColumnSizes) 
{
    if (numRows <= 0) return NULL; // 防止无效输入  
    *returnSize = numRows;//返回数据的长度等于输入的数据
    *returnColumnSizes = (int*)malloc(sizeof(int)*numRows);//为行分配空间
    int** result = (int**)malloc(sizeof(int*)*numRows);    //为指针分配空间

    for(int i = 0; i < numRows; i++)//行
    {
        (*returnColumnSizes)[i] = i + 1;//第i行有i+1个元素
        result[i] = (int*)malloc(sizeof(int) * (i + 1));
        for(int j = 0; j < i + 1; j++)//列
        {
            if(j == 0 || j == i)result[i][j] = 1;
            else
            {
                result[i][j] = result[i - 1][j - 1] + result[i - 1][j];
            }
        }
    }
    return result;
}